//
//  WJCenterController.m
//  JerryIos
//
//  Created by 王军 on 2018/2/5.
//  Copyright © 2018年 王军. All rights reserved.
//

#import "WJCenterController.h"
#import "UIViewController+MMDrawerController.h"

@interface WJCenterController ()

@end

@implementation WJCenterController

/**
 *  加载控制器的时候设置打开抽屉模式
 */
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //设置打开抽屉模式
    [self.mm_drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"Demo";
    
    //设置导航栏的按钮
    UIBarButtonItem *barItem1 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"navbar_back_normal"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtn)];
    UIBarButtonItem *barItem2 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"icon_coin_normal"] style:UIBarButtonItemStylePlain target:self action:@selector(leftBtn)];
    self.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:barItem1,barItem2, nil];
  
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"icon_friend_recomment_normal"] style:UIBarButtonItemStylePlain target:self action:@selector(rightBtn)];
}

-(void)backBtn{
    [self.mm_drawerController dismissViewControllerAnimated:YES completion:nil];
}

-(void)leftBtn{
    //这里的话是通过遍历循环拿到之前在AppDelegate中声明的那个MMDrawerController属性，然后判断是否为打开状态，如果是就关闭，否就是打开(初略解释，里面还有一些条件)
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideLeft animated:YES completion:nil];
}
-(void)rightBtn{
    [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:nil];
}

@end
